﻿using FB.Data.Models;
using FB.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace FB.Providers.AEInfo
{
    [Table("BASE_Locations", Schema = "ae")]
    public class Location : FBAuditModel, IFullName
    {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }

        [Required]
        [Column(Order = 1), ForeignKey("RoomSize")]
        [StringLength(8), Index("UIX_Location", 1, IsUnique = true)]
        public string BCHCode { get; set; }

        [Column(Order = 2), ForeignKey("RoomSize")]
        [StringLength(32), Index("UIX_Location", 2, IsUnique = true)]
        public string Room { get; set; }

        [StringLength(32), Index("UIX_Location", 3, IsUnique = true)]
        public string Seat { get; set; }

        [ForeignKey("BCHCode")]
        public virtual Branch Branch { get; set; }

        public virtual RoomSize RoomSize { get; set; }

        [NotMapped]
        public string FullName { get { return string.Format("{0} {1} {2}", Branch != null ? Branch.FullName : string.Empty, Room, Seat); } }
    }


    [Table("BASE_RoomSize", Schema = "ae")]
    public class RoomSize : FBAuditModel
    {
        [Key, StringLength(8), Column(Order = 1)]
        public string BCHCode { get; set; }

        [Key, StringLength(32), Column(Order = 2)]
        public string Room { get; set; }

        public decimal? Size { get; set; }

        [StringLength(256)]
        public string AreaCode { get; set; }

        public int? Order { get; set; }
    }


    [Table("BASE_Branches", Schema = "ae")]
    public class Branch : FBAuditModel, IFullName
    {
        [Key, StringLength(8)]
        public string Code { get; set; }

        [StringLength(256)]
        public string FullName { get; set; }
    }

}
